package WaiBao;

import java.util.Arrays;

public class HouRuiLiang {
    public static void main(String[] args) {
        String[] name= {"薛伟伟(班长)", "候清(副班长)", "小李(学习委员)", "张德发(文艺委员)", "张洪海", "李典", "王猛", "王强", "王梓旭", "王阳明", "王大促", "王帅帅",
                "张靓颖", "张杰", "张亚", "张文翰", "李文瀚", "李文函", "杨文静", "杨文杰", "杨口岸", "李上方", "李勋", "张德玉", "张泽楷", "凌泽旭", "李慧东", "刘慧慧",
                "谢娜", "侯瑞靓(学生)"};//考生本人:侯瑞靓(学生)
        int[] age = {22, 21,19,20,20, 19, 21,22,18, 22,19,19, 21, 19, 21,20, 21, 19, 20, 19, 19,21, 21, 21, 20, 23, 19,22,21, 19};//考生年龄：19岁

        double[] chukong1 = {80, 66, 88, 71, 77, 79, 75, 80, 73, 80, 64, 72, 71, 79, 65, 78, 62, 90, 86, 88, 92, 91, 95, 88, 75, 74, 78, 74, 85, 96};
        double[] chukong2 = {85, 71, 74, 85, 80, 77, 73, 89, 70, 74, 65, 70, 85, 74, 90, 74, 74, 79, 64, 65, 91, 71, 96, 85, 88, 84, 77, 95, 91, 96};
        double[] chukong3 = {77, 84, 74, 83, 71, 61, 78, 80, 84, 60, 63, 80, 75, 75, 65, 68, 69, 69, 96, 93, 92, 81, 95, 95, 79, 84, 77, 71, 80, 96};

        double heshi1;//代表每个学生的总分
        double heshi2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            heshi1 = chukong1[i] + chukong2[i] +chukong3[i];
//            heshi2 = ( heshi1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +heshi1);
//            System.out.println(name[i] + "的平均分为:" +heshi2);
//        }



        double penwu1 = 0,penwu2 = 0;
        double[] weisheng = new double[30];
//        for (int i = 0; i < 30; i++) {
//            penwu1 = chukong1[i] + chukong2[i] + chukong3[i];
//            penwu2= (penwu1 * 1.0) / 3;
//            weisheng[i] = penwu2;
//        }
//
//        for (int i = 0; i <weisheng.length - 1; i++) {
//            for (int j = 0; j < weisheng.length - i - 1; j++) {
//                if (weisheng[j] < weisheng [j + 1]) {
//                    double tep =weisheng[j];
//                    weisheng[j] =weisheng[j + 1];
//                    weisheng[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(weisheng[i]);
//        }

        double chuxi1 = 0,chuxi2 = 0,chuxi3 = 0;//计算每门课的平均分
        double meiyou1 = 0,meiyou2 = 0, meiyou3 = 0;//计算每门课标准差
        double houiz1 = 0,houiz2 = 0,houiz3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < chukong1.length; i++) {
            sum2+=chukong1[i];
        }
        chuxi1 = (sum2*1.0)/30;
        System.out.println("生物化学的班级平均分为:"+chuxi1);
        double Sum = 0;
        for (int i = 0; i <chukong2.length; i++) {
            Sum+=chukong2[i];
        }
        chuxi2 = (Sum*1.0)/30;
        System.out.println("微生物学的班级平均分为:"+chuxi2);
        double sum = 0;
        for (int i = 0; i <chukong3.length; i++) {
            sum+=chukong3[i];
        }
        chuxi3 = (sum*1.0)/30;
        System.out.println("人体组织解剖学的班级平均分为:"+ chuxi3);


//
        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < chukong1.length; i++) {
            c1+= (chukong1[i] -chuxi1)*(chukong1[i] -chuxi1);
        }
        meiyou1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:"+meiyou1);

        for (int i = 0; i <chukong2.length; i++) {
            c2+= (chukong2[i] -chuxi2)*(chukong2[i] - chuxi2);
        }
        meiyou2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:"+meiyou2);

        for (int i = 0; i < chukong3.length; i++) {
            c3+= (chukong3[i] -chuxi3)*(chukong3[i] -chuxi3);
        }
        meiyou3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:"+meiyou3);
//
//
        Arrays.sort(chukong1);
        Arrays.sort(chukong2);
        Arrays.sort(chukong3);
        houiz1 =(chukong1[14]+chukong1[15])*1.0/2;
        houiz2 =(chukong2[14]+chukong2[15])*1.0/2;
        houiz3 =(chukong3[14]+chukong3[15])*1.0/2;
        System.out.println("生物化学的中位数为:"+houiz1);
        System.out.println("微生物学的中位数为:"+houiz2);
        System.out.println("人体组织解剖学的中位数为:"+houiz3);
//



    }
}
